package com.silverhaze.diamond.client.ui.panel;

import javax.swing.*;
import java.awt.*;

/**
 * Author: Ivan Babanin
 * © Lizard Software, 2007 y.
 */
public class ImagePanel extends JPanel {
    private ImageIcon imageIcon;

    public ImagePanel(ImageIcon imageIcon) {
        this.imageIcon = imageIcon;
        setSize(imageIcon.getIconWidth(), imageIcon.getIconHeight());
    }

    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;

        Image aboutImg = imageIcon.getImage();
        g2d.drawImage(aboutImg, 0, 0, imageIcon.getImageObserver());
    }

    public ImageIcon getImageIcon() {
        return imageIcon;
    }

    public int getWidth() {
        return imageIcon.getIconWidth();
    }

    public int getHeight() {
        return imageIcon.getIconHeight();
    }

    public Dimension getSize() {
        return new Dimension(getWidth(), getHeight());
    }
}

